1
bash
This demonstrates the usage of the printf
command in Bash for formatted output, including strings, integers, floats, and writing to files.
printf "Hello %s, I'm %s" Sven Olga #=> "Hello Sven, I'm Olga printf "1 + 1 = %d" 2 #=> "1 + 1 = 2" printf "This is how you print a float: %f" 2 #=> "This is how you print a float: 2.000000" printf '%s\n' '#!/bin/bash' 'echo hello' >file # format string is applied to each group of arguments printf '%i+%i=%i\n' 1 2 3 4 5 9
bash internaldata manipulationsstring manipulation and expansionsformatted output